﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Net;

namespace Arcadium.GameEntities.Projectiles
{
    /// <summary>
    /// Bullets; horisontally flying bullets, not affected by gravity.
    /// </summary>
    abstract class Bullet : UpdatableProjectile
    {
        #region Fields

        #endregion

        #region Initialization

        public Bullet(World world, NetworkGamer shooter, Vector2 position, Vector2 velocity) 
            : base(world, shooter, position, velocity)
        {

        }

        #endregion

        #region Update

        public override bool Update(GameTime gameTime)
        {
            Position += (float)gameTime.ElapsedGameTime.TotalSeconds * velocity;

            if (World.Map.CheckCollision(Position))
            {
                //TODO: Event at impact?
                return true;
            }

            // But this??
            //foreach (Character enemy in World.Enemies)
            //{
            //    Vector2 diff = position - previousPosition;
            //    float distanceTraveled = diff.Length();
            //    diff.Normalize();
            //    for (int l = 0; l < distanceTraveled; l++)
            //    {
            //        Vector2 temp = position + diff * l;
            //        if (enemy.GetBoundingRectangle().Contains((int)temp.X, (int)temp.Y))
            //        {
            //            enemy.Harm(damage);
            //            return true;
            //        }
            //    }
            //}



            previousPosition = Position;
            return false;
        }

        #endregion

    }
}
